import * as pierService from '../../services/design/pierServices';
import { notification } from 'antd';
export default {

    namespace: 'pier',
    state: {
        title: '',
        current: {},
        piers: [],
    },
    reducers: {
        addpier(state, { payload: pier }) {
            return { ...state, piers: [...state.piers ? state.piers : [], pier] };
        }
    },
    effects: {
        *add({ payload: { values, onSuccess, onError } }, { call, put, select }) {
            const res = yield call(pierService.addPier, { ...values });
            if (res && res.data && res.data.code == "200") {
                notification.info({ message: "添加桥墩成功" });
                onSuccess(res.data.data);
                yield put({
                    type: 'addpier',
                    payload: res.data.data
                });
            }else{
                onError(res&&res.data?res.data.message:'服务器连接失败')
            }

        }
    }
}